package com.gss.system.controller;

import com.gss.common.core.controller.BaseController;
import com.gss.entity.R;
import com.gss.entity.enums.ConstantEnum;
import com.gss.entity.sys.dto.SysRole;
import com.gss.entity.sys.vo.SysRoleMenuVo;
import com.gss.system.service.ISysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author DYang
 * @date 2023/6/17
 */
@Api(tags = "角色管理")
@CrossOrigin
@RestController
@RequestMapping("/role")
public class SysRoleController extends BaseController<SysRole> {

    @Autowired
    private ISysRoleService sysRoleService;

    @ApiOperation(value = "角色关联菜单",tags = "角色管理")
    @PostMapping("/oauthMenu")
    public R<String> oauthMenu(@RequestBody SysRoleMenuVo entity){
        if (entity == null) {
            return R.error(ConstantEnum.PARAM_ERROR);
        }
        return sysRoleService.oauthMenu(entity);
    }

    @ApiOperation(value = "角色撤销菜单",tags = "角色管理")
    @DeleteMapping("/deleteMenu")
    public R<String> deleteMenu(@RequestBody List<Integer> idList){
        if (idList == null) {
            return R.error(ConstantEnum.PARAM_ERROR);
        }
        return sysRoleService.deleteMenu(idList);
    }
}
